﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class SystemManage_AdminAdd : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {

        }
    }

    #region Web 窗体设计器生成的代码

    protected override void OnLoad(EventArgs e)
    {
        isRequestLogin = true;                                  //是否需要登录
        RequestLoginPage = this.Request.Url.AbsoluteUri;        //获取决对Url
        isAtFramePageLogin = true;                              //是框架页

        base.OnLoad(e);
    }

    #endregion

    protected void btnBuy_Click(object sender, EventArgs e)
    {
        if (tbUserName.Text.Trim() == "")
        {
            Shove._Web.JavaScript.Alert(this.Page, "请输入管理员ID。");
            return;
        }

        if (tbUserRealityName.Text.Trim() == "")
        {
            Shove._Web.JavaScript.Alert(this.Page, "请输入管理员ID真实姓名。");
            return;
        }

        if (tbUserPassword.Text == "")
        {
            Shove._Web.JavaScript.Alert(this.Page, "请输入一级密码。");
            return;
        }

        if (tbUserPassword_2.Text != tbUserPassword.Text)
        {
            Shove._Web.JavaScript.Alert(this.Page, "输入的两次一级密码不一致。");
            return;
        }

        if (tbUserPassword2.Text == "")
        {
            Shove._Web.JavaScript.Alert(this.Page, "请输入二级密码。");
            return;
        }

        if (tbUserPassword2_2.Text != tbUserPassword2.Text)
        {
            Shove._Web.JavaScript.Alert(this.Page, "输入的两次二级密码不一致。");
            return;
        }

        string CustomerNo = tbUserName.Text.Trim();
        string CustomerName =  tbUserRealityName.Text.Trim();
        Int16 CustomerTypeID = 0;                     //总公司管理人员
        string Password1 = PublicFunction.EncryptPassword(tbUserPassword.Text.Trim());
        string Password2 = PublicFunction.EncryptPassword(tbUserPassword2.Text.Trim());  
        string Tel = "";
        string Mobile = "";
        string QQ = "";
        string Email = "";
        string PostCode = "";
        int CityID = 1;
        string Address = "";
        string Fax = "";                    //传真
        string Other = "";                  //其它联系方式
        string Sex = rblSex.SelectedValue;

        DateTime Birthday = DateTime.Now;
        Int16 CertTypeID = 1;               //证书类型ID
        string CertNo = "";                 //证书编号
        int BankTypeID = 1;                 //银行名
        string BankNameDetail = "";         //开户行名
        string BankCardNo = "";             //帐号
        string BankCustName = "";           //帐户名
        int DeptID = 1;                     //部门ID
        long RegisterOperID = -1;           //注册操作员
        string Remark = "总公司管理员";
        long RegisterShopID = _Site.ID;     //站点ID
        long SurrogateID = -1;              //代理商ID (网店前台会员，一般不享受结算奖金)
        long CommendID = -1;
        long ParentID = -1;
        Int16 LR = 0;
        bool IsLock = false;                //是否允许登录后台
        bool IsActivation = true;           //是否激活
        bool IsSurrogate = false;           //是否为代理商            

        long NewID = 0;                     //新注册会员ID
        string ReturnDescription = "";

        int i = DAL.Procedures.P_CustomerAdd(CustomerNo, CustomerName, CustomerTypeID, Password1, Password2, Tel, Mobile, QQ, Email, PostCode, CityID, Address, Fax, Other, Sex, Birthday, CertTypeID, CertNo, BankTypeID, BankNameDetail, BankCardNo, BankCustName, DeptID,
            RegisterOperID, Remark, RegisterShopID, SurrogateID, CommendID, ParentID, LR, false, IsLock, IsActivation, IsSurrogate, ref NewID, ref ReturnDescription);
        if (i >= 0)
        {
            Shove._Web.JavaScript.Alert(this.Page, "管理员新增成功！");
        }
        else
        {
            Shove._Web.JavaScript.Alert(this.Page, ReturnDescription);
        }

    }

}
